home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / apps.to.go / DTS.Lib / DTS.Lib.headers / ListControl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-11  |  30.9 KB  |  762 lines  |  [TEXT/MPS ]

  1. #ifndef __LISTCONTROL__
  2. #define __LISTCONTROL__
  3.  
  4. #ifndef __TYPES__
  5. #include <Types.h>
  6. #endif
  7.  
  8. #ifndef __LISTS__
  9. #include <Lists.h>
  10. #endif
  11.  
  12. #ifndef __WINDOWS__
  13. #include <Windows.h>
  14. #endif
  15.  
  16. typedef void    (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  17. typedef short    (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  18. typedef Boolean    (*CLKeyFilterProcPtr)(ListHandle list, EventRecord *event);
  19.  
  20. typedef struct CLDataRec {
  21.     short                    mode;
  22.     CLGetCompareDataProcPtr    getCompareData;
  23.     CLDoCompareDataProcPtr    doCompareData;
  24.     CLKeyFilterProcPtr        keyFilter;
  25. } CLDataRec;
  26. typedef CLDataRec *CLDataPtr, **CLDataHndl;
  27.  
  28. void            CLActivate(Boolean makeActive, ListHandle listHndl);
  29.     /*
  30.     **    ¶ Change activate state of list control to designated state.
  31.     **
  32.     **    INPUT:    aboveLayer        This is the layer above the layer to create.
  33.     **    INPUT:    makeActive:        true to make the control the active control.
  34.     **                            false to inactivate the control.
  35.     **            listHndl:        The list to activate or deactivate.
  36.     **
  37.     **    Activate this List record.  Activation is not done by calling LActivate.  The active
  38.     **    control is indicated by the 2-pixel thick border around the List control.  This allows
  39.     **    all List controls in a window to display which cells are selected.  This behavior can
  40.     **    be overridden by calling LActivate on the List record for List controls.
  41.     **
  42.     **    Human interface dictates that at most only a single List control has this active border.
  43.     **    For this reason, this function scans for other List controls in the window and removes
  44.     **    the border from any other that it finds. */
  45.  
  46. Boolean            CLClick(WindowPtr window, EventRecord *event, short *action);
  47.     /*
  48.     **    ¶ Handle a mouseDown for a list control.
  49.     **
  50.     **    INPUT:    window        The window to check for a List control click in.
  51.     **            event        The mouseDown event.
  52.     **    OUTPUT:    action        Pointer to a short to hold the resulting action.
  53.     **                        Pass in nil if you don't care.
  54.     **                            If 0 returned:    No action taken.
  55.     **                            If 1 returned:    The active list control used the click.
  56.     **                            If -1 returned:    A new List control was activated
  57.     **                                            (and the old one deactivated.)
  58.     **    RESULT:    Boolean        True if a List control used the event.
  59.     **
  60.     **    This is called when a mouseDown occurs in the content of a window.  It returns true if the
  61.     **    mouseDown caused a List action to occur.  Events that are handled include if the user
  62.     **    clicks on a scrollbar that is associated with a List control. */
  63.  
  64. ControlHandle    CLCtlHit(void);
  65.     /*
  66.     **    ¶ Return List control that was found by last call to FindControl.
  67.     **
  68.     **    RESULT:    ControlHandle
  69.     **
  70.     **    The List control that was hit by calling FindControl is saved in a global variable, since
  71.     **    the CDEF has no way of returning what kind it was.  To determine that it was a List control
  72.     **    that was hit, first call this function.  The first call returns the old value in the global
  73.     **    variable, plus it resets the global to nil.  Then call FindControl, and then call this
  74.     **    function again.  If it returns nil, then a List control wasn't hit.  If it returns non-nil,
  75.     **    then it was a List control that was hit, and specifically the one returned. */
  76.  
  77. Boolean            CLEvent(WindowPtr window, EventRecord *event, short *action);
  78.     /*
  79.     **    ¶ Handle the event if it applies to the active List control.
  80.     **
  81.     **    INPUT:    window        The window the event should be processed in.
  82.     **            event        The event to be processed.
  83.     **            action:        Used to return the action taken by CLClick.
  84.     **                        Pass in nil if you don't care.
  85.     **                        For click events:
  86.     **                            If 0 returned:    No action taken.
  87.     **                            If 1 returned:    The active list control used the click.
  88.     **                            If -1 returned:    A new List control was activated
  89.     **                                            (and the old one deactivated.)
  90.     **                        For key events:
  91.     **                            If 0 returned:     No action taken.
  92.     **                            If 1 returned:     Key positioning occured on the active control.
  93.     **
  94.     **    RESULT:    Boolean        True if a List control used the event.
  95.     **
  96.     **    Handle the event if it applies to the active List control.  If some action occured due
  97.     **    to the event, return true. */
  98.  
  99. ListHandle        CLFindActive(WindowPtr window);
  100.     /*
  101.     **    ¶ Returns the active List control, if any.
  102.     **
  103.     **    INPUT:    window        The window to check for an active List control.
  104.     **    RESULT:    ListHandle    The active List control found (nil if none).
  105.     **
  106.     **    Returns the active List control, if any.  If nil is passed in, then the return value
  107.     **    represents whatever List control is active, independent of what window it is in.  If a
  108.     **    window is passed in, then it returns a List control only if the active control is in the
  109.     **    specified window.  If the active List control is in some other window, then nil
  110.     **    is returned. */
  111.  
  112. ControlHandle    CLFindCtl(WindowPtr window, EventRecord *event, ListHandle *listHndl,
  113.                           ControlHandle *ctlHit);
  114.     /*
  115.     **    ¶ See if a List control or related scrollbar was clicked on.
  116.     **
  117.     **    INPUT:    window            The window to check for a hit.
  118.     **            event            The mouseDown event to hit-test with.
  119.     **    OUTPUT:    listHndl        The list hit on, or nil if none hit.
  120.     **                            Pass in nil if you don’t care.
  121.     **            ctlHit            The control hit on, or nil if none hit.
  122.     **                            Pass in nil if you don’t care.
  123.     **                            (Note that the control returned here may be a related scrollbar.)
  124.     **    RESULT:    ControlHandle    The List control hit, or nil for none.
  125.     **
  126.     **    This determines if a List control was clicked on, or if a related scrollbar was
  127.     **    clicked on.  If a List control or List scrollbar was clicked on, then true is returned,
  128.     **    as well as the List handle and the handle to the view control. */
  129.  
  130. ListHandle        CLFromScroll(ControlHandle scrollCtl, ControlHandle *retCtl);
  131.     /*
  132.     **    ¶ Find the List record that is related to the indicated scrollbar.
  133.     **
  134.     **    INPUT:    scrollCtl        The scrollbar to look up.
  135.     **            retCtl            The List control handle.  Pass in nil if you don’t care.
  136.     **    RESULT:    listHndl        The list related to the scrollbar.
  137.     **
  138.     **    Find the List record that is related to the indicated scrollbar. */
  139.  
  140. ListHandle        CLGetList(WindowPtr window, short lnum);
  141.     /*
  142.     **    ¶ Get the Nth List control in the control list of a window.
  143.     **
  144.     **    INPUT:    window        The window whose control list is to be scanned.
  145.     **            lnum        The list number to return.
  146.     **    RESULT:    listHndl    The Nth list control in the window list.
  147.     **
  148.     **    Get the Nth List control in the control list of a window. */
  149.  
  150. short            CLInsert(ListHandle listHndl, char *data, short dataLen, short row, short col);
  151.     /*
  152.     **    ¶ Insert a cell alphabetically into the list.
  153.     **
  154.     **    INPUT:    listHndl    The list to be inserted into.
  155.     **            data        Pointer to data to insert.
  156.     **            dataLen        Length of data to insert.
  157.     **            row            Row to insert into (or -1 if to be determined).
  158.     **            col            Column to insert into (or -1 if to be determined).
  159.     **    RESULT:    short        The position at which the data was inserted.
  160.     **
  161.     **    Insert a cell alphabetically into the list.  Whichever parameter is passed in as -1, either
  162.     **    row or column, that is the dimension that is determined.  The method of handling he
  163.     **    comparisons has been changed to allow customization of the list data and search methods.
  164.     **    Before, it was assumed that the cell content was text, and that the default LDEF was being
  165.     **    used.  If you write a custom LDEF that uses a different data format, you had problems before.
  166.     **    Now, with the addition of two procedure pointers, you can customize the data comparisons.
  167.     **    The two new procs are:
  168.     **        1) getCompareData
  169.     **        2) doCompareData
  170.     **    The first proc, getCompareData, if nil, simply gets the data out of the cell for comparison
  171.     **    purposes.  If it is not nil, then the proc is called, and the proc gets the data out of the
  172.     **    cell.  The proc can then get whatever data it needs to for the purpose of comparing to other
  173.     **    cells and finding the insert location in the list.  The second proc, doCompareData, if nil
  174.     **    tells the List control to call IUMagString for the purpose of comparison.  If it is not nil,
  175.     **    then the proc is called instead of IUMagString, and you can do whatever kind of comparison
  176.     **    you wish.  Your proc is a replacement for IUMagString, so it should be of that form, except
  177.     **    that the prototype is a C prototype, instead of type pascal.
  178.     **
  179.     **    The prototypes are:
  180.     **
  181.     **    typedef void  (*CLGetCompareDataProcPtr)(void *src, short srclen, void *dst, short *dstlen);
  182.     **    typedef short (*CLDoCompareDataProcPtr)(void *ptra, void *ptrb, short lena, short lenb);
  183.     **
  184.     **    The GetCompareData proc is passed in a reference to the data, and a length.  Its job is to
  185.     **    then return the data and data length of what the compare data should look like.
  186.     **
  187.     **    The DoCompareData proc is just a replacement for IUMagString.  Parameters are as expected.
  188.     **    To set the procs, you first need to have a List control.  The below example assumes that
  189.     **    the window has a single List control.
  190.     **
  191.     **
  192.     **    static short    MyDoCompareData(void *ptra, void *ptrb, short lena, short lenb);
  193.     **    static void        MyGetCompareData(void *src, short srclen, void *dst, short *dstlen);
  194.     **    static Boolean    MyKeyFilter(ListHandle list, EventRecord *event);
  195.     **
  196.     **        ControlHandle    ctl;
  197.     **        ListHandle        list;
  198.     **        CLDataHndl        listData;
  199.     **
  200.     **        ctl = CLNext(window, &list, nil, 1, false);
  201.     **        listData = (CLDataHndl)(*ctl)->contrlData;
  202.     **        (*listData)->getCompareData = MyGetCompareData;
  203.     **        (*listData)->doCompareData  = MyDoCompareData;
  204.     **        (*listData)->keyFilter      = MyKeyFilter;
  205.     **
  206.     **            The above code first gets the first (only) List control in window.  It then gets
  207.     **            the listData record so that it can store the compare procs into the list.  The
  208.     **            procs are then stored into the record.
  209.     */
  210.  
  211. Boolean            CLKey(WindowPtr window, EventRecord *event);
  212.     /*
  213.     **    ¶ Handle a keypress for a list control.
  214.     **
  215.     **    INPUT:    window        The window to check for a List control keypress in.
  216.     **            event        The keypress event.
  217.     **    RESULT:    Boolean        True if a List control used the event.
  218.     **
  219.     **    See if the keypress event applies to the List control, and if it does, handle it and
  220.     **    return true.  The keypress can only be used by the List control if the List control
  221.     **    has key-positioning set. */
  222.  
  223. ListHandle        CLNew(short viewID, Boolean vis, Rect *vRect, short numRows, short numCols,
  224.                       short cellHeight, short cellWidth, short theLProc,
  225.                       WindowPtr window, short mode);
  226.     /*
  227.     **    ¶ Create a List control for the window.
  228.     **
  229.     **    This List control implementation does the following:
  230.     **
  231.     **    1)    Makes using lists in a non-dialog window easier.
  232.     **    2)    The List is automatically associated with the window, since
  233.     **        it is in the window's control list.
  234.     **    4)    Updating of the List is much simpler, since all that is
  235.     **        necessary is to draw the control (or all the window's controls with
  236.     **        a DrawControls call).
  237.     **    5)    What isn't handled automatically by tracking the control can be handled
  238.     **        with a direct call.  There are simple calls to handle List events.
  239.     **    6)    When you close the window, the ListRecord is disposed of.
  240.     **        (This automatic disposal can easily be defeated.)
  241.     **
  242.     **    To create a List control, you only need a single call.  For example:
  243.     **
  244.     **        list = CLNew(rViewCtl,            Resource ID of view control for List control.
  245.     **                     true,                Initially visible.
  246.     **                     &viewRect,            View rect of list.
  247.     **                     numRows,            Number of rows to create List with.
  248.     **                     numCols,            Number of columns to create List with.
  249.     **                     cellHeight,
  250.     **                     cellWidth,
  251.     **                     theLProc,            Custom List procedure resource ID.
  252.     **                     window,            Window to hold List control.
  253.     **                     clHScroll | blBrdr | clActive);    Horizontal scrollbar, active List.
  254.     **
  255.     **    The various choices for the List control are defined as follows:
  256.     **
  257.     **    #define clHScroll        0x0002
  258.     **    #define clVScroll        0x0008
  259.     **    #define clActive        0x0020
  260.     **    #define clShowActive    0x0040
  261.     **    #define clKeyPos        0x0080
  262.     **    #define clTwoStep        0x0100
  263.     **    #define clHasGrow        0x0200
  264.     **    #define clDrawIt        0x8000
  265.     **
  266.     **    clHScroll:        Create a list that includes a horizontal scrollbar.
  267.     **    clVScroll:        Create a list that includes a vertical scrollbar.
  268.     **    clActive:        Make this the initially active control for the window.
  269.     **    clShowActive:    When the control is active, show that it is by drawing a selection
  270.     **                    border around the control.  This is the new 7.0 human-interface
  271.     **                    method of showing which control is active.  (It also works in system 6.)
  272.     **    clKeyPos:        Allow list positioning, based on user keypresses.  This assumes that
  273.     **                    the list is alphabetized so that key presses for location make sense.
  274.     **                    If typing by the user is fast enough, multiple characters will be
  275.     **                    used for the positioning.
  276.     **    clTwoStep:        When using IsCtlEvent(), you may want the initial click on a List
  277.     **                    control to just select the control, or you may wish the click to start
  278.     **                    tracking in addition to selecting the control.  The tracking is
  279.     **                    considered the second step.  By setting this bit, you indicate that you
  280.     **                    want control selection and item selection to be a 2-step process.
  281.     **                    Setting this bit means that it will take 2 separate clicks by the
  282.     **                    user to select an item in the list if the list is inactive.
  283.     **    clHasGrow:        This makes sure that there is space for the growIcon if the list
  284.     **                    has a scrollbar.  If the list occupies an entire window, then if there
  285.     **                    is only one scrollbar, the scrollbar has to be shrunk to make room
  286.     **                    for the growIcon.  The List Manager supposedly has this ability, but
  287.     **                    it doesn't work.  The List control manages it correctly.
  288.     **    clDrawIt:        This is a List manager flag that is needed for the LNew() call.
  289.     **
  290.     **
  291.     **    If the CLNew call succeeds, you then have a List control in your window.  It will be
  292.     **    automatically disposed of when you close the window.  If you don't want this to happen,
  293.     **    then you can detach it from the view control which owns it.  To do this, you would to
  294.     **    the following:
  295.     **
  296.     **        viewCtl = CLViewFromList(theListHndl);
  297.     **        if (viewCtl) SetCRefCon(viewCtl, nil);
  298.     **
  299.     **    The view control keeps a reference to the List record in the refCon.  If the refCon is
  300.     **    cleared, then the view control does nothing.  So, all that is needed to detach a List
  301.     **    record from a view control is to set the view control's refCon nil.  Now if you close the
  302.     **    window, you will still have the List record.
  303.     **
  304.     **
  305.     **    To remove a List control completely from a window, just dispose of the view
  306.     **    control that holds the List record.  To do this, just do something like the below:
  307.     **
  308.     **        DisposeControl(CLViewFromList(theListHndl));
  309.     **
  310.     **    This completely disposes of the List control.
  311.     **
  312.     **
  313.     **    Events for the List record are handled nearly automatically.  Just make the following call:
  314.     **
  315.     **        CLEvent(window, eventPtr, &action);
  316.     **
  317.     **    If the event was handled, true is returned.  If the event is false, then the event doesn't
  318.     **    belong to a List control, and further processing of the event should be done.
  319.     */
  320.  
  321. ControlHandle    CLNext(WindowPtr window, ListHandle *listHndl, ControlHandle ctl,
  322.                        short dir, Boolean justActive);
  323.     /*
  324.     **    ¶ Get the next List control in the window.
  325.     **
  326.     **    INPUT:    window            The window to check for a List control keypress in.
  327.     **            ctl                The last control found (nil searchs from beginning of control list).
  328.     **            dir                Search direction (1 for forward, -1 for backward).
  329.     **            justActive        True if only active, visible controls should be returned.
  330.     **    RESULT:    ControlHandle    Next control found, based on criteria.
  331.     **
  332.     **    Get the next List control in the window.  You pass it a control handle for the view control,
  333.     **    or nil to start at the beginning of the window.  It returns both a List handle and the view
  334.     **    control handle for that List record.  If none is found, nil is returned.  This allows you to
  335.     **    repeatedly call this function and walk through all the List controls in a window. */
  336.  
  337. void            CLPrint(RgnHandle clipRgn, ListHandle listHndl, short *row, short *col,
  338.                         short leftEdge, Rect *drawRct);
  339.     /*
  340.     **    ¶ Print List Control cells into the designated rectangle.
  341.     **
  342.     **    INPUT:    clipRgn            Region to clip output to.
  343.     **            listHndl        List to print.
  344.     **            leftEdge        Don’t print cells left of this column.
  345.     **    IN/OUT    row                Starting row to print (first row not printed returned here).
  346.     **            col                Starting column to print (first column not printed returned here).
  347.     **            drawRct            Print cells inside rect.  Rect is also shrunk to bound the
  348.     **                            cells that did print.
  349.     **
  350.     **    From the starting row or column, print as many cells as will fit into the designated rect.
  351.     **    Pass in a starting row and column, and they will be adjusted to indicate the first cell
  352.     **    that didn't fit into the rect.  If all remaining cells were printed, the row is returned
  353.     **    as -1.  The bottom of the rect to print in is also adjusted to indicate where the actual
  354.     **    cut-off point was. */
  355.  
  356. short            CLRowOrColSearch(ListHandle listHndl, void *data, short dataLen,
  357.                                  short row, short col);
  358.     /*
  359.     **    ¶ Find the location in the list where the data would belong if inserted.
  360.     **
  361.     **    INPUT:    listHndl        List to search.
  362.     **            data            Pointer to data to search for, of whatever type.
  363.     **            dataLen            Length of data to search for.
  364.     **            row                Row to restrict search to, or -1 if doing row search.
  365.     **            col                Column to restrict search to, or -1 if doing column search.
  366.     **    RESULT:    short            Insertion location for either row or column.
  367.     **
  368.     **    Find the location in the list where the data would belong if inserted.  The row and column
  369.     **    are passed in.  If either is -1, that is the dimension that will be determined and returned.
  370.     **    The two comparison procs getCompareData and doCompareData are used in this function.
  371.     **
  372.     **    __________
  373.     **
  374.     **    Also see:    CLInsert. */
  375.  
  376. void            CLUpdate(RgnHandle clipRgn, ListHandle list);
  377.     /*
  378.     **    ¶ Draw the List control in the correct mode.
  379.     **
  380.     **    INPUT:    clipRgn        Draw only within this region.
  381.     **            list        List to draw.
  382.     **
  383.     **    Draw the List control in the correct mode. */
  384.  
  385. ControlHandle    CLViewFromList(ListHandle listHndl);
  386.     /*
  387.     **    ¶ Given a list, return the related wrapper control.
  388.     **
  389.     **    INPUT:    listHndl        List assumably wrapped by a control.
  390.     **    RESULT:    ControlHandle    Control wrapping list (or nil if none).
  391.     **
  392.     **    Return the control handle for the view control that owns the List record.  Use this to find
  393.     **    the view to do customizations such as changing the update procedure for this List control. */
  394.  
  395. ListHandle        CLWindActivate(WindowPtr window, Boolean displayIt);
  396.     /*
  397.     **    ¶ Given a list, return the related wrapper control.
  398.     **
  399.     **    INPUT:    listHndl        List assumably wrapped by a control.
  400.     **    RESULT:    ControlHandle    Control wrapping list (or nil if none).
  401.     **
  402.     **    This window is becoming active or inactive.  The borders of the List controls need to be
  403.     **    redrawn due to this.  For each List control in the window, redraw the active border. */
  404.  
  405. void            CLSize(ListHandle list, short newH, short newV);
  406.     /*
  407.     **    ¶ Resize the control and related things.
  408.     **
  409.     **    INPUT:    list        List to resize.
  410.     **            newH        New width for control.
  411.     **            newV        New height for control.
  412.     **
  413.     **    This resizes the list and it's viewCtl  All parts are resized, including the scrollbars,
  414.     **    and active indicator. */
  415.  
  416. void            CLMove(ListHandle list, short newH, short newV);
  417.     /*
  418.     **    ¶ Move the control and related things.
  419.     **
  420.     **    INPUT:    list        List to move.
  421.     **            newH        New horizontal location for control.
  422.     **            newV        New vertical location for control.
  423.     **
  424.     **    This moves the list and it's viewCtl  All parts are moved, including the scrollbars,
  425.     **    and active indicator. */
  426.  
  427. void            CLShow(ListHandle list);
  428.     /*
  429.     **    ¶ Show the control and related things.
  430.     **
  431.     **    INPUT:    list        List to show.
  432.     **
  433.     **    This shows the list and related parts, including the scrollbars and active indicator. */
  434.  
  435. Rect            CLHide(ListHandle list);
  436.     /*
  437.     **    ¶ Hide the control and related things.
  438.     **
  439.     **    INPUT:    list        List to hide.
  440.     **
  441.     **    This hides the list and related parts, including the scrollbars and active indicator. */
  442.  
  443. void            CLVInitialize(void);
  444.     /*
  445.     **    ¶ Initialize variable-sized cells List control code.
  446.     **
  447.     **    Call this upon startup of any application that wants to be able to use the
  448.     **    variable-size cell feature of the List control.  For AppsToGo-created List control
  449.     **    definitions to be variable-size automatically, this must be called first.  You can
  450.     **    call CLVVariableSizeCells at a later time to utilize this feature, as it
  451.     **    calls CLVInitialize.
  452.     **
  453.     **
  454.     **    A number of developers have expressed a desire to have the List Manager support
  455.     **    variable-size cells.  In response to this, the List control has been extended to
  456.     **    support variable-size rows and columns.
  457.     **
  458.     **    The first problem is where to store the size for each row and column.  This
  459.     **    implementation expects the sizes for the individual column widths to be stored
  460.     **    in row 0, cells 1 through numCols, and the individual row widths to be stored in
  461.     **    column 0, rows 1 through numRows.  The values are placed in the cells in decimal
  462.     **    ascii.  (This is so that the AppsToGo editor can easily be used to create lists
  463.     **    with variable-size cells.  You just enter the decimal ascii value in the editor.)
  464.     **    Any row or column without a decimal ascii entry for the size will get the regular
  465.     **    size for a cell.
  466.     **
  467.     **    Since row 0 and column 0 are used to store the widths, these cells are not available
  468.     **    in the list.  They are not displayed, and you can not scroll into them.  Due to this,
  469.     **    the list is one column narrower and one row shorter than a regular list.
  470.     **
  471.     **    The variable-size list expects the dataBounds upper-left to be 0,0.  Any other
  472.     **    upper-left for the dataBounds will cause the variable-size list to misbehave.  
  473.     **    A dataBounds other than 0,0 is very rare, and unnecessary, so it seemed better
  474.     **    to not have the code to support it, than to code for a feature almost never used.
  475.     **
  476.     **    Bit 14 of the mode field needs to be set to true for the list to be converted to
  477.     **    a variable-size list.  Also, CLVInitialize() has to be called at some time, or else
  478.     **    the framework will create the list as a regular list.  (Start.c is a good place.)
  479.     **
  480.     **    For the most part, the List control is managed just like the regular List control.
  481.     **    If you need to access the List itself, it is stored in the refCon of the List control.
  482.     **    However, since the List Manager calls aren't expecting the list to be of variable-size
  483.     **    cells, you can't make all of the calls to the List Manager you would normally make.
  484.     **
  485.     **    If you create a regular list, and then place decimal ascii values in row 0 and
  486.     **    column 0 (where needed), you can then directly call CLVVariableSizeCells() for that
  487.     **    list, and it will be converted.  (If you call CLVVariableSizeCells() directly, you
  488.     **    don't actually need to call CLVInitialize(), as it does this for you.)
  489.     **
  490.     **    Below are the List Manager calls, and how they should be handled when using a
  491.     **    variable-size list:
  492.     **
  493.     **
  494.     **    LActivate:
  495.     **        Call CLActivate().
  496.     **
  497.     **    LAddColumn:
  498.     **        Call CLVAddColumn().
  499.     **
  500.     **    LAddRow:
  501.     **        Call CLVAddRow().
  502.     **
  503.     **    LAddToCell:
  504.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  505.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  506.     **
  507.     **    LAutoScroll:
  508.     **        Call CLVAutoScroll().
  509.     **
  510.     **    LCellSize:
  511.     **        New meaning.  You can set the size of a column or row.  To do, do the following:
  512.     **            1)    LGetCell() for the row or column width to change.  Example:
  513.     **                    For column 3,
  514.     **                        short    len, locSize[2];
  515.     **                        Point    cell;
  516.     **
  517.     **                        len = 2 * sizeof(short);
  518.     **                        cell.h = 3;
  519.     **                        cell.v = 0;
  520.     **                        LGetCell(locSize, &len, cell, list);
  521.     **            2)    Set the size (2nd word) to new size (locSize[1] = newSize).
  522.     **            3)    LSetCell(locSize, len, cell, list);
  523.     **            4)    CLVAdjustCellLocs(list)
  524.     **            5)    CLVUpdate(list)
  525.     **
  526.     **    LClick:
  527.     **        Call CLVClick().
  528.     **
  529.     **    LClrCell:
  530.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  531.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  532.     **
  533.     **    LDelColumn:
  534.     **        Call LDelColumn(), followed by CLVAdjustCellLocs() and CLVUpdate().
  535.     **
  536.     **    LDelRow:
  537.     **        Call LDelRow(), followed by CLVAdjustCellLocs() and CLVUpdate().
  538.     **
  539.     **    LDispose:
  540.     **        Don't call it.  Dispose by DisposeControl(CLViewFromList(list)).
  541.     **
  542.     **    LDoDraw:
  543.     **        Don't call it.  The variable-sized control should always have doDraw false.
  544.     **        (You can hide the list by making the control invisible.)
  545.     **
  546.     **    LDraw:
  547.     **        Call CLVDraw().
  548.     **
  549.     **    LFind:
  550.     **        Okay to call.
  551.     **
  552.     **    LGetCell:
  553.     **        Okay to call.
  554.     **
  555.     **    LGetSelect:
  556.     **        Okay to call.
  557.     **
  558.     **    LLastClick:
  559.     **        Okay to call.
  560.     **
  561.     **    LNextCell:
  562.     **        Okay to call.
  563.     **
  564.     **    LRect:
  565.     **        Call CLVGetCellInfo().
  566.     **        It's overkill, since it gets everything, but tough.  There aren't too many
  567.     **        occasions for the app to get the cell rect, so I'm not going to have another
  568.     **        call to do it.
  569.     **
  570.     **    LScroll:
  571.     **        Don't call.
  572.     **
  573.     **    LSearch:
  574.     **        Okay to call.
  575.     **
  576.     **    LSetCell:
  577.     **        Okay to call.  Cell won't be drawn, though.  Standard list drawing is disabled
  578.     **        when using variable-size cell mode.  Call CLVDraw() afterwards to draw the cell.
  579.     **
  580.     **    LSetSelect:
  581.     **        Call CLVSetSelect().
  582.     **
  583.     **    LUpdate:
  584.     **        Call CLVUpdate
  585.     */
  586.  
  587. void            CLVVariableSizeCells(ListHandle list);
  588.     /*
  589.     **    ¶ Convert a List control to one that has variable size rows and columns.
  590.     **
  591.     **    INPUT:    list        List to convert to variable-size cells.
  592.     **
  593.     **    This is called to convert a List control to one that has variable size rows and columns. */
  594.  
  595. void            CLVAdjustScrollBars(ListHandle list);
  596.     /*
  597.     **    ¶ Adjust the scrollbars to reflect new list size.
  598.     **
  599.     **    INPUT:    list        List whose scrollbars need adjusting.
  600.     **
  601.     **    After doing other operations, call this to adjust the scrollbars to reflect the
  602.     **    the new List size. */
  603.  
  604. void            CLVFindCell(ListHandle list, Point mouseLoc, Point *cell);
  605.     /*
  606.     **    ¶ Given a mouse location, find the cell that contains it.
  607.     **
  608.     **    INPUT:    list        List to examine.
  609.     **            mouseLoc    Point to find the cell for.
  610.     **    OUTPUT:    cell        Cell containing the mouseLoc point.
  611.     **
  612.     **    Since cells are of variable size, it is more difficult to determine which cell contains
  613.     **    a particular point.  CLVFindCell will do this.  If in fact the point is not contained by
  614.     **    any cell, -1, -1 is returned. */
  615.  
  616. void            CLVGetCellRect(ListHandle list, short xx, short yy, Rect *cbnds);
  617.     /*
  618.     **    ¶ Given a cell xx,yy, return its bounding rect.
  619.     **
  620.     **    INPUT:    list        List to get bounding rect for.
  621.     **            xx            Column of cell.
  622.     **            yy            Row of cell.
  623.     **    OUTPUT:    cbnds        Bounding rect of cell.
  624.     **
  625.     **    Get the bounding rect of a cell.  If that cell is invisible, then the rect returned
  626.     **    will be the empty rect. */
  627.  
  628. void            CLVGetVisCells(ListHandle list, Rect *visRct);
  629.     /*
  630.     **    ¶ Get the bounding rect of the cells visible within the Control's view rect.
  631.     **
  632.     **    INPUT:    list        List to get visible-area bounding rect for.
  633.     **    OUTPUT:    visRct        Rect bounding all cells visible within control.
  634.     **
  635.     **    This call is used instead of the visRect field of a list. */
  636.  
  637. void            CLVGetCellInfo(ListHandle list, short xx, short yy, Rect *cbnds, short *cellNum,
  638.                                short *select, short *ofst, short *len);
  639.     /*
  640.     **    ¶ Get plenty of information on a particular cell.
  641.     **
  642.     **    INPUT:    list        List to get info on.
  643.     **            xx            Column of cell to get info on.
  644.     **            yy            Row of cell to get info on.
  645.     **    OUTPUT:    cbnds        Bounding rect of cell.
  646.     **            cellNum        Number of cell in list.
  647.     **            select        True if cell is selected.
  648.     **            ofst        Offset into the data area for cell's data.
  649.     **            len            Length of cell's data.
  650.     **
  651.     **    This call is really more for the variable-list code.  You may find it useful, however. */
  652.  
  653. void            CLVSetSelect(Boolean select, Point cell, ListHandle list);
  654.     /*
  655.     **    ¶ Set the select state for a variable-size cell.
  656.     **
  657.     **    INPUT:    select        Desired select state (true or false).
  658.     **            cell        Cell to set select state for.
  659.     **            list        List containing cell to set select state for.
  660.     **
  661.     **    Whenever you have a variable-cell-size list, use this instead of LSetSelect. */
  662.  
  663. void            CLVAutoScroll(ListHandle list);
  664.  
  665. void            CLVAdjustCellLocs(ListHandle list);
  666.  
  667. short            CLVAddColumn(short count, short colNum, short ww, ListHandle list);
  668.     /*
  669.     **    ¶ Add a column to a variable-size cell.
  670.     **
  671.     **    INPUT:    short        Number of columns to add.
  672.     **            colNum        Column number to insert new columns into.
  673.     **            ww            Width of new column(s).
  674.     **            list        List to add new column(s) to.
  675.     **
  676.     **    Use this instead of LAddColumn. */
  677.  
  678. short            CLVAddRow(short count, short rowNum, short hh, ListHandle list);
  679.     /*
  680.     **    ¶ Add a row to a variable-size cell.
  681.     **
  682.     **    INPUT:    short        Number of rows to add.
  683.     **            rowNum        Row number to insert new columns into.
  684.     **            hh            Height of new rows(s).
  685.     **            list        List to add new rows(s) to.
  686.     **
  687.     **    Use this instead of LAddRow. */
  688.  
  689. void            CLVDraw(Point cell, ListHandle list);
  690.     /*
  691.     **    ¶ Draw a single variable-size cell.
  692.     **
  693.     **    INPUT:    cell        Cell to draw.
  694.     **            list        List containing cell to draw.
  695.     **
  696.     **    Draw a single variable-size cell. */
  697.  
  698. Boolean            CLVClick(Point mouseLoc, short modifiers, ListHandle list);
  699.     /*
  700.     **    ¶ Handle a mouseDown for a variable-cell-size list control.
  701.     **
  702.     **    INPUT:    mouseLoc    The click location the list needs to handle.
  703.     **            modifiers    Event record 
  704.     **            list        The list which is to receive the mouse click.
  705.     **    RESULT:    Boolean        True if user double-clicked on cell.
  706.     **
  707.     **    This is used instead of calling LClick.  You probably don't need to call it diretly, as you
  708.     **    would call CLClick or CLEvent.  CLClick (and possibly CLEvent) would call this if the list
  709.     **    was a variable-cell-size list. */
  710.  
  711. void            CLVUpdate(RgnHandle clipRgn, ListHandle list);
  712.     /*
  713.     **    ¶ Draw the variable-cell-size list control in the correct mode.
  714.     **
  715.     **    INPUT:    clipRgn        Draw only within this region.
  716.     **            list        List to draw.
  717.     **
  718.     **    Draw the variable-cell-size list control in the correct mode. */
  719.  
  720. void            CLVCallDefProc(short lMessage, short lSelect, Rect *lRect, Cell lCell,
  721.                                short lDataOffset, short lDataLen, ListHandle list);
  722.     /*
  723.     **    ¶ Calls the variable-cell-size list's LDEF.
  724.     **
  725.     **    INPUT:    clipRgn        Draw only within this region.
  726.     **            list        List to draw.
  727.     **
  728.     **    Calls the variable-cell-size list's LDEF. */
  729.  
  730.  
  731. typedef void            (*CLActivateProcPtr)(Boolean active, ListHandle listHndl);
  732. typedef Boolean            (*CLClickProcPtr)(WindowPtr window, EventRecord *event, short *action);
  733. typedef ControlHandle    (*CLCtlHitProcPtr)(void);
  734. typedef ListHandle        (*CLFindActiveProcPtr)(WindowPtr window);
  735. typedef Boolean            (*CLKeyProcPtr)(WindowPtr window, EventRecord *event);
  736. typedef ControlHandle    (*CLNextProcPtr)(WindowPtr window, ListHandle *listHndl, ControlHandle ctl, short dir, Boolean justActive);
  737. typedef ControlHandle    (*CLViewFromListProcPtr)(ListHandle listHndl);
  738. typedef ListHandle        (*CLWindActivateProcPtr)(WindowPtr window, Boolean displayIt);
  739.  
  740. typedef void            (*CLVVariableSizeCellsProcPtr)(ListHandle list);
  741. typedef void            (*CLVGetCellRectProcPtr)(ListHandle list, short xx, short yy, Rect *cbnds);
  742. typedef void            (*CLVUpdateProcPtr)(RgnHandle clipRgn, ListHandle list);
  743. typedef void            (*CLVAutoScrollProcPtr)(ListHandle list);
  744. typedef void            (*CLVSetSelectProcPtr)(Boolean select, Point cell, ListHandle list);
  745. typedef Boolean            (*CLVClickProcPtr)(Point mouseLoc, short modifiers, ListHandle list);
  746. typedef void            (*CLVAdjustScrollBarsProcPtr)(ListHandle list);
  747.  
  748.  
  749. #define rListCtl        4016
  750.  
  751. #define clHScroll        0x0002
  752. #define clVScroll        0x0008
  753. #define clActive        0x0020
  754. #define clShowActive    0x0040
  755. #define clKeyPos        0x0080
  756. #define clTwoStep        0x0100
  757. #define clHasGrow        0x0200
  758. #define clVariable        0x4000
  759. #define clDrawIt        0x8000
  760.  
  761. #endif
  762.